/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <unistd.h>

#include "crypto_framework_asym_cipher_test.h"
#include "crypto_rand.h"
#include "blob.h"
#include "log.h"

#include <gtest/gtest.h>

using namespace testing::ext;
namespace Unittest::CryptoFrameworkAsymCipherNapiTest {
class OHCryptoFrameworkAsymCipherNapiTest : public testing::Test {
public:
    static void SetUpTestCase() {};
    static void TearDownTestCase() {};
    void SetUp() {};
    void TearDown() {};
};

class ASYMKEY_ASYM_CIPHER_TEST : public testing::TestWithParam<AsymCipherSpec> {
    public:
        static void SetUpTestCase() {}
        static void TearDownTestCase() {}
};

class ASYMKEY_ASYM_SEG_CIPHER_TEST : public testing::TestWithParam<AsymSegmentCipherSpec> {
    public:
        static void SetUpTestCase() {}
        static void TearDownTestCase() {}
};

static OH_CryptoKeyPair *OHTEST_GenAsymKey(const char *algoName)
{
    OH_CryptoKeyPair *keyPair = nullptr;
    OH_CryptoAsymKeyGenerator *ctx = nullptr;

    EXPECT_EQ(OH_CryptoAsymKeyGenerator_Create(algoName, &ctx), CRYPTO_SUCCESS);
    if (strcmp(algoName, "RSA8192") == 0) {
        Crypto_DataBlob pubKeyBlob = { .data = g_rsa8192pubKey, .len = sizeof(g_rsa8192pubKey) };
        Crypto_DataBlob priKeyBlob = { .data = g_rsa8192priKey, .len = sizeof(g_rsa8192priKey) };
        EXPECT_EQ(OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubKeyBlob, &priKeyBlob, &keyPair), CRYPTO_SUCCESS);
    } else if (strcmp(algoName, "RSA4096") == 0) {
        Crypto_DataBlob pubKeyBlob = { .data = g_rsa4096pubKey, .len = sizeof(g_rsa4096pubKey) };
        Crypto_DataBlob priKeyBlob = { .data = g_rsa4096priKey, .len = sizeof(g_rsa4096priKey) };
        EXPECT_EQ(OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubKeyBlob, &priKeyBlob, &keyPair), CRYPTO_SUCCESS);
    } else if (strcmp(algoName, "RSA3072") == 0) {
        Crypto_DataBlob pubKeyBlob = { .data = g_rsa3072pubKey, .len = sizeof(g_rsa3072pubKey) };
        Crypto_DataBlob priKeyBlob = { .data = g_rsa3072priKey, .len = sizeof(g_rsa3072priKey) };
        EXPECT_EQ(OH_CryptoAsymKeyGenerator_Convert(ctx, CRYPTO_DER, &pubKeyBlob, &priKeyBlob, &keyPair), CRYPTO_SUCCESS);
    } else {
        EXPECT_EQ(OH_CryptoAsymKeyGenerator_Generate(ctx, &keyPair), CRYPTO_SUCCESS);
    }

    OH_CryptoAsymKeyGenerator_Destroy(ctx);
    return keyPair;
}

static void OHTEST_DoAsymCipher(const char *algoName, OH_CryptoKeyPair *keyPair,
    Crypto_CipherMode mode, const Crypto_DataBlob *msg, Crypto_DataBlob *cipherData)
{
    OH_CryptoAsymCipher *ctx = nullptr;
    
    EXPECT_EQ(OH_CryptoAsymCipher_Create(algoName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, mode, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, msg, cipherData), CRYPTO_SUCCESS);

    OH_CryptoAsymCipher_Destroy(ctx);
}

static void OHTEST_DoSegmentAsymCipher(const char *algoName, OH_CryptoKeyPair *keyPair,
    size_t blockSize, Crypto_CipherMode mode, Crypto_DataBlob *msg, Crypto_DataBlob *cipherText)
{
    OH_CryptoAsymCipher *ctx = nullptr;
    int quotient = msg->len / blockSize;
    int remainder = msg->len % blockSize;
    uint8_t *data = msg->data;
    size_t len = msg->len;
    Crypto_DataBlob *dataBlob = msg;
    size_t cipherLen = 0;
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};

    cipherText->data = (uint8_t *)malloc(cipherText->len);
    uint8_t *tmp = cipherText->data;
    EXPECT_TRUE(cipherText->data != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(algoName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, mode, keyPair), CRYPTO_SUCCESS);
    for (int i = 0; i < quotient; i++) {
        dataBlob->len = blockSize;
        EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, dataBlob, &cipherData), CRYPTO_SUCCESS);
        (void)memcpy(cipherText->data, cipherData.data, cipherData.len);
        cipherText->data += cipherData.len;
        cipherLen += cipherData.len;
        dataBlob->data += blockSize;
        OH_Crypto_FreeDataBlob(&cipherData);
    }
    if (remainder) {
        dataBlob->len = remainder;
        EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, dataBlob, &cipherData), CRYPTO_SUCCESS);
        cipherLen += cipherData.len;
        (void)memcpy(cipherText->data, cipherData.data, cipherData.len);
    }
    
    dataBlob->data = data;
    dataBlob->len = len;
    cipherText->data = tmp;
    cipherText->len = cipherLen;
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_Crypto_FreeDataBlob(&cipherData);
}

AsymCipherSpec g_asymCipherSpec[] = {
    /* RSA NoPadding */
    {"RSA512", "RSA512|NoPadding", OHTEST_RSA_512_KEYSIZE},
    {"RSA768",	"RSA768|NoPadding", OHTEST_RSA_768_KEYSIZE},
    {"RSA1024",	"RSA1024|NoPadding", OHTEST_RSA_1024_KEYSIZE},
    {"RSA2048",	"RSA2048|NoPadding", OHTEST_RSA_2048_KEYSIZE},
    {"RSA3072",	"RSA3072|NoPadding", OHTEST_RSA_3072_KEYSIZE},
    {"RSA4096",	"RSA4096|NoPadding", OHTEST_RSA_4096_KEYSIZE},
    {"RSA8192",	"RSA8192|NoPadding", OHTEST_RSA_8192_KEYSIZE},
    {"RSA512", "RSA|NoPadding", OHTEST_RSA_512_KEYSIZE},
    /* RSA PKCS1 */
    {"RSA512", "RSA512|PKCS1", OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA768",	"RSA768|PKCS1", OHTEST_RSA_768_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA1024",	"RSA1024|PKCS1", OHTEST_RSA_1024_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA2048",	"RSA2048|PKCS1", OHTEST_RSA_2048_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA3072",	"RSA3072|PKCS1", OHTEST_RSA_3072_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA4096",	"RSA4096|PKCS1", OHTEST_RSA_4096_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA8192",	"RSA8192|PKCS1", OHTEST_RSA_8192_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA512", "RSA|PKCS1", OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    /* RSA512 PKCS1_OAEP */
    {"RSA512", "RSA512|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA512", "RSA512|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA512", "RSA|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    /* RSA768 PKCS1_OAEP */
    {"RSA768", "RSA768|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|MD5|MGF1_SHA384", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|MD5|MGF1_SHA512", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA1|MGF1_SHA384", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA1|MGF1_SHA512", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA224|MGF1_SHA384", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA224|MGF1_SHA512", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA256|MGF1_MD5", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA256|MGF1_SHA1", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA256|MGF1_SHA224", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA256|MGF1_SHA256", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA768", "RSA768|PKCS1_OAEP|SHA256|MGF1_SHA384", OHTEST_RSA_768_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    /* RSA1024 PKCS1_OAEP */
    {"RSA1024", "RSA1024|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|MD5|MGF1_SHA384", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|MD5|MGF1_SHA512", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA1|MGF1_SHA384", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA1|MGF1_SHA512", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA224|MGF1_SHA384", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA224|MGF1_SHA512", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA256|MGF1_MD5", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA1", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA224", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA256", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA384", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA512", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA384|MGF1_MD5", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA384|MGF1_SHA1", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA384|MGF1_SHA224", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA384|MGF1_SHA256", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA384|MGF1_SHA384", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA1024", "RSA1024|PKCS1_OAEP|SHA384|MGF1_SHA512", OHTEST_RSA_1024_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    /* RSA2048 PKCS1_OAEP */
    {"RSA2048", "RSA2048|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|MD5|MGF1_SHA384", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|MD5|MGF1_SHA512", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA1|MGF1_SHA384", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA1|MGF1_SHA512", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA224|MGF1_SHA384", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA224|MGF1_SHA512", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA256|MGF1_MD5", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA1", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA224", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA256", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA384", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA512", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA384|MGF1_MD5", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA384|MGF1_SHA1", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA384|MGF1_SHA224", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA384|MGF1_SHA256", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA384|MGF1_SHA384", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA384|MGF1_SHA512", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA512|MGF1_MD5", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA512|MGF1_SHA1", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA512|MGF1_SHA224", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA512|MGF1_SHA256", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA512|MGF1_SHA384", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA2048", "RSA2048|PKCS1_OAEP|SHA512|MGF1_SHA512", OHTEST_RSA_2048_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    /* RSA3072 PKCS1_OAEP */
    {"RSA3072", "RSA3072|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|MD5|MGF1_SHA384", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|MD5|MGF1_SHA512", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA1|MGF1_SHA384", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA1|MGF1_SHA512", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA384", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA512", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA256|MGF1_MD5", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA256|MGF1_SHA1", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA256|MGF1_SHA224", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA256|MGF1_SHA256", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA256|MGF1_SHA384", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA256|MGF1_SHA512", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA384|MGF1_MD5", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA1", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA224", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA256", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA384", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA512", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA512|MGF1_MD5", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA512|MGF1_SHA1", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA512|MGF1_SHA224", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA512|MGF1_SHA256", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA512|MGF1_SHA384", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA3072", "RSA3072|PKCS1_OAEP|SHA512|MGF1_SHA512", OHTEST_RSA_3072_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    /* RSA4096 PKCS1_OAEP */
    {"RSA4096", "RSA4096|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|MD5|MGF1_SHA384", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|MD5|MGF1_SHA512", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA1|MGF1_SHA384", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA1|MGF1_SHA512", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA224|MGF1_SHA384", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA224|MGF1_SHA512", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA256|MGF1_MD5", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA256|MGF1_SHA1", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA256|MGF1_SHA224", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA256|MGF1_SHA256", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA256|MGF1_SHA384", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA256|MGF1_SHA512", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA384|MGF1_MD5", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA384|MGF1_SHA1", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA384|MGF1_SHA224", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA384|MGF1_SHA256", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA384|MGF1_SHA384", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA384|MGF1_SHA512", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA512|MGF1_MD5", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA512|MGF1_SHA1", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA512|MGF1_SHA224", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA512|MGF1_SHA256", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA512|MGF1_SHA384", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA4096", "RSA4096|PKCS1_OAEP|SHA512|MGF1_SHA512", OHTEST_RSA_4096_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    /* RSA8192 PKCS1_OAEP */
    {"RSA8192", "RSA8192|PKCS1_OAEP|MD5|MGF1_MD5", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|MD5|MGF1_SHA1", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|MD5|MGF1_SHA224", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|MD5|MGF1_SHA256", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|MD5|MGF1_SHA384", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|MD5|MGF1_SHA512", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA1|MGF1_MD5", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA1|MGF1_SHA1", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA1|MGF1_SHA224", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA1|MGF1_SHA256", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA1|MGF1_SHA384", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA1|MGF1_SHA512", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA224|MGF1_MD5", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA224|MGF1_SHA1", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA224|MGF1_SHA224", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA224|MGF1_SHA256", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA224|MGF1_SHA384", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA224|MGF1_SHA512", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA224_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA256|MGF1_MD5", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA256|MGF1_SHA1", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA256|MGF1_SHA224", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA256|MGF1_SHA256", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA256|MGF1_SHA384", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA256|MGF1_SHA512", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA256_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA384|MGF1_MD5", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA384|MGF1_SHA1", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA384|MGF1_SHA224", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA384|MGF1_SHA256", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA384|MGF1_SHA384", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA384|MGF1_SHA512", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA384_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA512|MGF1_MD5", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA512|MGF1_SHA1", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA512|MGF1_SHA224", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA512|MGF1_SHA256", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA512|MGF1_SHA384", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    {"RSA8192", "RSA8192|PKCS1_OAEP|SHA512|MGF1_SHA512", OHTEST_RSA_8192_KEYSIZE - 2 * OHTEST_SHA512_DIGIESTSIZE - 2},
    /* SM2_256 */
    {"SM2_256", "SM2_256|MD5", 256},
    {"SM2_256", "SM2_256|SHA1", 256},
    {"SM2_256", "SM2_256|SHA224", 256},
    {"SM2_256", "SM2_256|SHA256", 256},
    {"SM2_256", "SM2_256|SHA384", 256},
    {"SM2_256", "SM2_256|SHA512", 256},
    {"SM2_256", "SM2_256|SM3", 256},
    {"SM2_256", "SM2|SM3", 256},
};

INSTANTIATE_TEST_CASE_P(OHCryptoFrameworkAsymCipherNapiTest, ASYMKEY_ASYM_CIPHER_TEST, ::testing::ValuesIn(g_asymCipherSpec));

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0100
* @tc.name OHCryptoFrameworkAsymCipherNapiTest/ASYMKEY_ASYM_CIPHER_TEST.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0100/x
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_P(ASYMKEY_ASYM_CIPHER_TEST, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0100, TestSize.Level0)
{
    AsymCipherSpec AsymCipherData = GetParam();
    OH_CryptoRand *randCtx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(AsymCipherData.algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, AsymCipherData.pkLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == AsymCipherData.pkLen);
    msgBlob.data[0] = 0x00;
    (void)OHTEST_DoAsymCipher(AsymCipherData.cipherName, keyPair, CRYPTO_ENCRYPT_MODE, &msgBlob, &cipherData);
    (void)OHTEST_DoAsymCipher(AsymCipherData.cipherName, keyPair, CRYPTO_DECRYPT_MODE, &cipherData, &plainData);
    if (msgBlob.len == plainData.len) {
        EXPECT_TRUE(memcmp(plainData.data, msgBlob.data, msgBlob.len) == 0);
    }
    EXPECT_TRUE(msgBlob.len == plainData.len);

    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
    OH_Crypto_FreeDataBlob(&plainData);
}

AsymSegmentCipherSpec g_asymSegmentCipherSpec[] = {
    /* RSA PKCS1 */
    {"RSA512", "RSA512|PKCS1", OHTEST_RSA_512_KEYSIZE, OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA768",	"RSA768|PKCS1", OHTEST_RSA_768_KEYSIZE, OHTEST_RSA_768_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA1024",	"RSA1024|PKCS1", OHTEST_RSA_1024_KEYSIZE, OHTEST_RSA_1024_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA2048",	"RSA2048|PKCS1", OHTEST_RSA_2048_KEYSIZE, OHTEST_RSA_2048_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA3072",	"RSA3072|PKCS1", OHTEST_RSA_3072_KEYSIZE, OHTEST_RSA_3072_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA4096",	"RSA4096|PKCS1", OHTEST_RSA_4096_KEYSIZE, OHTEST_RSA_4096_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA8192",	"RSA8192|PKCS1", OHTEST_RSA_8192_KEYSIZE, OHTEST_RSA_8192_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
    {"RSA512", "RSA|PKCS1", OHTEST_RSA_512_KEYSIZE, OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE},
};
INSTANTIATE_TEST_CASE_P(OHCryptoFrameworkAsymCipherNapiTest, ASYMKEY_ASYM_SEG_CIPHER_TEST, ::testing::ValuesIn(g_asymSegmentCipherSpec));

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0200
* @tc.name OHCryptoFrameworkAsymCipherNapiTest/ASYMKEY_ASYM_SEG_CIPHER_TEST.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0200/x
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_P(ASYMKEY_ASYM_SEG_CIPHER_TEST, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0200, TestSize.Level0)
{
    AsymSegmentCipherSpec AsymCipherData = GetParam();
    OH_CryptoRand *randCtx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 2048 * 1024};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 1024};
    size_t blockSize = 20;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(AsymCipherData.algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, AsymCipherData.len, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == AsymCipherData.len);
    (void)OHTEST_DoSegmentAsymCipher(AsymCipherData.cipherName, keyPair, blockSize, CRYPTO_ENCRYPT_MODE, &msgBlob, &cipherData);
    (void)OHTEST_DoSegmentAsymCipher(AsymCipherData.cipherName, keyPair, AsymCipherData.pkLen, CRYPTO_DECRYPT_MODE, &cipherData, &plainData);
    EXPECT_TRUE(memcmp(plainData.data, msgBlob.data, msgBlob.len) == 0);
    EXPECT_EQ(msgBlob.len, plainData.len);

    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
    OH_Crypto_FreeDataBlob(&plainData);
}

static void OHTEST_DoSM2EncryptCipher(const char *algoName, OH_CryptoKeyPair *keyPair,
    size_t blockSize, Crypto_DataBlob *msg, Crypto_DataBlob *cipherText, int *cipherIndex)
{
    OH_CryptoAsymCipher *ctx = nullptr;
    int quotient = msg->len / blockSize;
    int remainder = msg->len % blockSize;
    uint8_t *data = msg->data;
    size_t len = msg->len;
    Crypto_DataBlob *dataBlob = msg;
    size_t cipherLen = 0;
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    int i = 0;

    cipherText->data = (uint8_t *)malloc(cipherText->len);
    uint8_t *tmp = cipherText->data;
    EXPECT_TRUE(cipherText->data != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(algoName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    for (i = 0; i < quotient; i++) {
        dataBlob->len = blockSize;
        EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, dataBlob, &cipherData), CRYPTO_SUCCESS);
        (void)memcpy(cipherText->data, cipherData.data, cipherData.len);
        cipherText->data += cipherData.len;
        cipherLen += cipherData.len;
        dataBlob->data += blockSize;
        cipherIndex[i] = cipherData.len;
        OH_Crypto_FreeDataBlob(&cipherData);
    }
    if (remainder) {
        dataBlob->len = remainder;
        EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, dataBlob, &cipherData), CRYPTO_SUCCESS);
        cipherLen += cipherData.len;
        cipherIndex[i] = cipherData.len;
        (void)memcpy(cipherText->data, cipherData.data, cipherData.len);
    }
    
    dataBlob->data = data;
    dataBlob->len = len;
    cipherText->data = tmp;
    cipherText->len = cipherLen;
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_Crypto_FreeDataBlob(&cipherData);
}

static void OHTEST_DoSM2DecryptCipher(const char *algoName, OH_CryptoKeyPair *keyPair,
    Crypto_DataBlob *msg, Crypto_DataBlob *cipherText, int *cipherIndex)
{
    OH_CryptoAsymCipher *ctx = nullptr;
    uint8_t *data = msg->data;
    size_t len = msg->len;
    Crypto_DataBlob *dataBlob = msg;
    size_t cipherLen = 0;
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    int i = 0;

    cipherText->data = (uint8_t *)malloc(cipherText->len);
    uint8_t *tmp = cipherText->data;
    EXPECT_TRUE(cipherText->data != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(algoName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    while (cipherIndex[i] != 0) {
        dataBlob->len = cipherIndex[i];
        EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, dataBlob, &cipherData), CRYPTO_SUCCESS);
        (void)memcpy(cipherText->data, cipherData.data, cipherData.len);
        cipherText->data += cipherData.len;
        cipherLen += cipherData.len;
        dataBlob->data += cipherIndex[i];
        i++;
        OH_Crypto_FreeDataBlob(&cipherData);
    }
    
    dataBlob->data = data;
    dataBlob->len = len;
    cipherText->data = tmp;
    cipherText->len = cipherLen;
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0300
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0300
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0300, TestSize.Level0)
{
    const char *algoName = "SM2_256";
    const char *cipherName = "SM2_256|SM3";
    OH_CryptoRand *randCtx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 2048};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 1024};
    size_t blockSize = 20;
    size_t msgLen = 53;
    int cipherIndex[64] = {0};

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    (void)OHTEST_DoSM2EncryptCipher(cipherName, keyPair, blockSize, &msgBlob, &cipherData, cipherIndex);
    (void)OHTEST_DoSM2DecryptCipher(cipherName, keyPair, &cipherData, &plainData, cipherIndex);
    EXPECT_TRUE(memcmp(plainData.data, msgBlob.data, msgBlob.len) == 0);
    EXPECT_EQ(msgBlob.len, plainData.len);

    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
    OH_Crypto_FreeDataBlob(&plainData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0400
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0400
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0400, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName = "RSA512|NoPadding";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - 1;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    msgBlob.data[0] = 0x00;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_OPERTION_ERROR);

    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0500
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0500
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0500, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName = "RSA512|PKCS1";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE + 1;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_OPERTION_ERROR);

    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0600
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0600
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0600, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName = "RSA512|PKCS1_OAEP|MD5|MGF1_MD5";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_MD5_DIGIESTSIZE - 2 + 1;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_OPERTION_ERROR);

    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0700
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0700
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0700, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName = "RSA512|PKCS1";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE;

    OH_CryptoKeyPair *keyPair1 = OHTEST_GenAsymKey(algoName);
    OH_CryptoKeyPair *keyPair2 = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair1 != nullptr && keyPair2 != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair1), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair1);
    OH_CryptoKeyPair_Destroy(keyPair2);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0800
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0800
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0800, TestSize.Level0)
{
    const char *algoName1 = "RSA512";
    const char *algoName2 = "RSA768";
    const char *cipherName = "RSA512|PKCS1";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE;

    OH_CryptoKeyPair *keyPair1 = OHTEST_GenAsymKey(algoName1);
    OH_CryptoKeyPair *keyPair2 = OHTEST_GenAsymKey(algoName2);
    EXPECT_TRUE(keyPair1 != nullptr && keyPair2 != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair1), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair1);
    OH_CryptoKeyPair_Destroy(keyPair2);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0900
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0900
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_0900, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName = "RSA512|PKCS1";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    cipherData.data[0]++;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);
    cipherData.data[0]--;
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_SUCCESS);
    EXPECT_TRUE(memcmp(plainData.data, msgBlob.data, msgBlob.len) == 0);
    EXPECT_EQ(msgBlob.len, plainData.len);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1000
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1000
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1000, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName1 = "RSA512|PKCS1";
    const char *cipherName2 = "RSA512|NoPadding";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName1, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName2, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_SUCCESS);
    EXPECT_TRUE(memcmp(plainData.data, msgBlob.data, msgBlob.len) != 0);
    EXPECT_EQ(OHTEST_RSA_512_KEYSIZE, plainData.len);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1100
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1100
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1100, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName1 = "RSA512|PKCS1";
    const char *cipherName2 = "RSA512|PKCS1_OAEP|MD5|MGF1_MD5";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - OHTEST_RSA_PKCS1_PADDING_SIZE;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName1, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName2, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1200
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1200
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1200, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName1 = "RSA512|PKCS1_OAEP|SHA1|MGF1_MD5";
    const char *cipherName2 = "RSA512|PKCS1_OAEP|MD5|MGF1_MD5";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE - 2 * OHTEST_SHA1_DIGIESTSIZE - 2;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName1, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName2, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1300
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1300
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1300, TestSize.Level0)
{
    const char *algoName = "RSA512";
    const char *cipherName2 = "RSA512|PKCS1";
    const char *cipherName1 = "RSA512|NoPadding";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 0};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t msgLen = OHTEST_RSA_512_KEYSIZE;

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    msgBlob.data[0] = 0x00;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName1, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_ENCRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &msgBlob, &cipherData), CRYPTO_SUCCESS);
    OH_CryptoAsymCipher_Destroy(ctx);
    ctx = nullptr;
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName2, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);
    
    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&plainData);
    OH_Crypto_FreeDataBlob(&cipherData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1400
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1400
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1400, TestSize.Level0)
{
    const char *algoName = "SM2_256";
    const char *cipherName = "SM2_256|SM3";
    OH_CryptoRand *randCtx = nullptr;
    OH_CryptoAsymCipher *ctx = nullptr;
    Crypto_DataBlob msgBlob = {.data = nullptr, .len = 0};
    Crypto_DataBlob cipherData = {.data = nullptr, .len = 2048};
    Crypto_DataBlob plainData = {.data = nullptr, .len = 0};
    size_t blockSize = 20;
    size_t msgLen = 53;
    int cipherIndex[64] = {0};

    OH_CryptoKeyPair *keyPair = OHTEST_GenAsymKey(algoName);
    EXPECT_TRUE(keyPair != nullptr);
    EXPECT_EQ(OH_CryptoRand_Create(&randCtx), CRYPTO_SUCCESS);
    EXPECT_TRUE(randCtx != nullptr);
    EXPECT_EQ(OH_CryptoRand_GenerateRandom(randCtx, msgLen, &msgBlob), CRYPTO_SUCCESS);
    EXPECT_TRUE(msgBlob.data != nullptr);
    EXPECT_TRUE(msgBlob.len == msgLen);
    (void)OHTEST_DoSM2EncryptCipher(cipherName, keyPair, blockSize, &msgBlob, &cipherData, cipherIndex);
    EXPECT_EQ(OH_CryptoAsymCipher_Create(cipherName, &ctx), CRYPTO_SUCCESS);
    EXPECT_TRUE(ctx != nullptr);
    EXPECT_EQ(OH_CryptoAsymCipher_Init(ctx, CRYPTO_DECRYPT_MODE, keyPair), CRYPTO_SUCCESS);
    cipherData.len = 100;
    EXPECT_EQ(OH_CryptoAsymCipher_Final(ctx, &cipherData, &plainData), CRYPTO_OPERTION_ERROR);

    OH_CryptoAsymCipher_Destroy(ctx);
    OH_CryptoKeyPair_Destroy(keyPair);
    OH_CryptoRand_Destroy(randCtx);
    OH_Crypto_FreeDataBlob(&msgBlob);
    OH_Crypto_FreeDataBlob(&cipherData);
    OH_Crypto_FreeDataBlob(&plainData);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1500
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1500
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1500, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t data[] = {
        0x30, 0x79, 0x02, 0x21, 0x00, 0x9b, 0x17, 0xa5, 0xd3, 0xac, 0xcc, 0xf3, 0x3c, 0x2e, 0x36, 0x23,
        0x99, 0x78, 0x17, 0x50, 0xc9, 0xdc, 0x3e, 0x1b, 0x57, 0x0e, 0xc9, 0x0b, 0x04, 0x1c, 0x18, 0x24,
        0x5e, 0x71, 0xe9, 0x02, 0x8c, 0x02, 0x20, 0x78, 0xc6, 0x6f, 0xda, 0x59, 0x82, 0xae, 0x5e, 0xb3,
        0x17, 0xd2, 0xe1, 0x9b, 0x73, 0xf6, 0x77, 0xed, 0x57, 0xd5, 0xe3, 0x46, 0xde, 0x6c, 0xc4, 0x19,
        0x38, 0x80, 0x96, 0x4c, 0x13, 0x6d, 0x2c, 0x04, 0x20, 0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac,
        0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47, 0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b,
        0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf, 0x04, 0x10, 0xf5, 0x89, 0xc8, 0xb5, 0xdf,
        0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    Crypto_DataBlob sm2Ciphertext = {.data = data, .len = sizeof(data)/sizeof(data[0])};
    Crypto_DataBlob c1_x = {.data = nullptr, .len = 0};
    Crypto_DataBlob c1_y = {.data = nullptr, .len = 0};
    Crypto_DataBlob c2 = {.data = nullptr, .len = 0};
    Crypto_DataBlob c3 = {.data = nullptr, .len = 0};
    Crypto_DataBlob new_c1_x = {.data = nullptr, .len = 0};
    Crypto_DataBlob new_c1_y = {.data = nullptr, .len = 0};
    Crypto_DataBlob new_c2 = {.data = nullptr, .len = 0};
    Crypto_DataBlob new_c3 = {.data = nullptr, .len = 0};
    Crypto_DataBlob new_sm2Ciphertext = {.data = nullptr, .len = 0};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(&sm2Ciphertext, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &c3), CRYPTO_SUCCESS);
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    spec = nullptr;
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(nullptr, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &c3), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Encode(spec, &new_sm2Ciphertext), CRYPTO_SUCCESS);
    EXPECT_TRUE(memcmp(new_sm2Ciphertext.data, sm2Ciphertext.data, new_sm2Ciphertext.len) == 0);
    EXPECT_EQ(new_sm2Ciphertext.len, sm2Ciphertext.len);
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    spec = nullptr;
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(&new_sm2Ciphertext, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &new_c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &new_c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &new_c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_GetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &new_c3), CRYPTO_SUCCESS);
    EXPECT_TRUE(memcmp(new_c1_x.data, c1_x.data, new_c1_x.len) == 0);
    EXPECT_TRUE(memcmp(new_c1_y.data, c1_y.data, new_c1_y.len) == 0);
    EXPECT_TRUE(memcmp(new_c2.data, c2.data, c2.len) == 0);
    EXPECT_TRUE(memcmp(new_c3.data, c3.data, new_c3.len) == 0);
    EXPECT_TRUE(new_c3.len == c3.len && new_c1_x.len == c1_x.len && new_c2.len == c2.len && new_c1_y.len == c1_y.len);

    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    OH_Crypto_FreeDataBlob(&new_c1_x);
    OH_Crypto_FreeDataBlob(&new_c1_y);
    OH_Crypto_FreeDataBlob(&new_c2);
    OH_Crypto_FreeDataBlob(&new_c3);
    OH_Crypto_FreeDataBlob(&c1_x);
    OH_Crypto_FreeDataBlob(&c1_y);
    OH_Crypto_FreeDataBlob(&c2);
    OH_Crypto_FreeDataBlob(&c3);
    OH_Crypto_FreeDataBlob(&new_sm2Ciphertext);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1600
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1600
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1600, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t c1_y_data[] = {
        0x2c, 0x6d, 0x13, 0x4c, 0x96, 0x80, 0x38, 0x19, 0xc4, 0x6c, 0xde, 0x46, 0xe3, 0xd5, 0x57, 0xed,
        0x77, 0xf6, 0x73, 0x9b, 0xe1, 0xd2, 0x17, 0xb3, 0x5e, 0xae, 0x82, 0x59, 0xda, 0x6f, 0xc6, 0x7
    };
    uint8_t c2_data[] = {
        0xf5, 0x89, 0xc8, 0xb5, 0xdf, 0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    uint8_t c3_data[] = {
        0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac, 0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47,
        0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b, 0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf
    };
    Crypto_DataBlob c1_y = {.data = c1_y_data, .len = sizeof(c1_y_data)/sizeof(c1_y_data[0])};
    Crypto_DataBlob c2 = {.data = c2_data, .len = sizeof(c2_data)/sizeof(c2_data[0])};
    Crypto_DataBlob c3 = {.data = c3_data, .len = sizeof(c3_data)/sizeof(c3_data[0])};
    Crypto_DataBlob sm2Ciphertext = {.data = nullptr, .len = 0};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(nullptr, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &c3), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Encode(spec, &sm2Ciphertext), CRYPTO_PARAMETER_CHECK_FAILED);
    
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    OH_Crypto_FreeDataBlob(&sm2Ciphertext);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1700
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1700
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1700, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t c1_x_data[] = {
        0x8c, 0x02, 0xe9, 0x71, 0x5e, 0x24, 0x18, 0x1c, 0x04, 0x0b, 0xc9, 0x0e, 0x57, 0x1b, 0x3e, 0xdc,
        0xc9, 0x50, 0x17, 0x78, 0x99, 0x23, 0x36, 0x2e, 0x3c, 0xf3, 0xcc, 0xac, 0xd3, 0xa5, 0x17, 0x9b
    };
    uint8_t c1_y_data[] = {
        0x2c, 0x6d, 0x13, 0x4c, 0x96, 0x80, 0x38, 0x19, 0xc4, 0x6c, 0xde, 0x46, 0xe3, 0xd5, 0x57, 0xed,
        0x77, 0xf6, 0x73, 0x9b, 0xe1, 0xd2, 0x17, 0xb3, 0x5e, 0xae, 0x82, 0x59, 0xda, 0x6f, 0xc6, 0x7
    };
    uint8_t c3_data[] = {
        0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac, 0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47,
        0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b, 0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf
    };
    Crypto_DataBlob c1_x = {.data = c1_x_data, .len = sizeof(c1_x_data)/sizeof(c1_x_data[0])};
    Crypto_DataBlob c1_y = {.data = c1_y_data, .len = sizeof(c1_y_data)/sizeof(c1_y_data[0])};
    Crypto_DataBlob c3 = {.data = c3_data, .len = sizeof(c3_data)/sizeof(c3_data[0])};
    Crypto_DataBlob sm2Ciphertext = {.data = nullptr, .len = 0};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(nullptr, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &c3), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Encode(spec, &sm2Ciphertext), CRYPTO_PARAMETER_CHECK_FAILED);
    
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    OH_Crypto_FreeDataBlob(&sm2Ciphertext);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1800
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1800
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1800, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t c1_x_data[] = {
        0x8c, 0x02, 0xe9, 0x71, 0x5e, 0x24, 0x18, 0x1c, 0x04, 0x0b, 0xc9, 0x0e, 0x57, 0x1b, 0x3e, 0xdc,
        0xc9, 0x50, 0x17, 0x78, 0x99, 0x23, 0x36, 0x2e, 0x3c, 0xf3, 0xcc, 0xac, 0xd3, 0xa5, 0x17, 0x9b
    };
    uint8_t c2_data[] = {
        0xf5, 0x89, 0xc8, 0xb5, 0xdf, 0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    uint8_t c3_data[] = {
        0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac, 0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47,
        0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b, 0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf
    };
    Crypto_DataBlob c1_x = {.data = c1_x_data, .len = sizeof(c1_x_data)/sizeof(c1_x_data[0])};
    Crypto_DataBlob c2 = {.data = c2_data, .len = sizeof(c2_data)/sizeof(c2_data[0])};
    Crypto_DataBlob c3 = {.data = c3_data, .len = sizeof(c3_data)/sizeof(c3_data[0])};
    Crypto_DataBlob sm2Ciphertext = {.data = nullptr, .len = 0};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(nullptr, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &c3), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Encode(spec, &sm2Ciphertext), CRYPTO_PARAMETER_CHECK_FAILED);
    
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    OH_Crypto_FreeDataBlob(&sm2Ciphertext);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1900
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1900
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_1900, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t c1_x_data[] = {
        0x8c, 0x02, 0xe9, 0x71, 0x5e, 0x24, 0x18, 0x1c, 0x04, 0x0b, 0xc9, 0x0e, 0x57, 0x1b, 0x3e, 0xdc,
        0xc9, 0x50, 0x17, 0x78, 0x99, 0x23, 0x36, 0x2e, 0x3c, 0xf3, 0xcc, 0xac, 0xd3, 0xa5, 0x17, 0x9b
    };
    uint8_t c1_y_data[] = {
        0x2c, 0x6d, 0x13, 0x4c, 0x96, 0x80, 0x38, 0x19, 0xc4, 0x6c, 0xde, 0x46, 0xe3, 0xd5, 0x57, 0xed,
        0x77, 0xf6, 0x73, 0x9b, 0xe1, 0xd2, 0x17, 0xb3, 0x5e, 0xae, 0x82, 0x59, 0xda, 0x6f, 0xc6, 0x7
    };
    uint8_t c2_data[] = {
        0xf5, 0x89, 0xc8, 0xb5, 0xdf, 0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    Crypto_DataBlob c1_x = {.data = c1_x_data, .len = sizeof(c1_x_data)/sizeof(c1_x_data[0])};
    Crypto_DataBlob c1_y = {.data = c1_y_data, .len = sizeof(c1_y_data)/sizeof(c1_y_data[0])};
    Crypto_DataBlob c2 = {.data = c2_data, .len = sizeof(c2_data)/sizeof(c2_data[0])};
    Crypto_DataBlob sm2Ciphertext = {.data = nullptr, .len = 0};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(nullptr, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Encode(spec, &sm2Ciphertext), CRYPTO_PARAMETER_CHECK_FAILED);
    
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    OH_Crypto_FreeDataBlob(&sm2Ciphertext);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_2000
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_2000
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_2000, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t data1[] = {
        0x30, 0x79, 0x02, 0x20, 0x9b, 0x17, 0xa5, 0xd3, 0xac, 0xcc, 0xf3, 0x3c, 0x2e, 0x36, 0x23,
        0x99, 0x78, 0x17, 0x50, 0xc9, 0xdc, 0x3e, 0x1b, 0x57, 0x0e, 0xc9, 0x0b, 0x04, 0x1c, 0x18, 0x24,
        0x5e, 0x71, 0xe9, 0x02, 0x8c, 0x02, 0x20, 0x78, 0xc6, 0x6f, 0xda, 0x59, 0x82, 0xae, 0x5e, 0xb3,
        0x17, 0xd2, 0xe1, 0x9b, 0x73, 0xf6, 0x77, 0xed, 0x57, 0xd5, 0xe3, 0x46, 0xde, 0x6c, 0xc4, 0x19,
        0x38, 0x80, 0x96, 0x4c, 0x13, 0x6d, 0x2c, 0x04, 0x20, 0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac,
        0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47, 0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b,
        0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf, 0x04, 0x10, 0xf5, 0x89, 0xc8, 0xb5, 0xdf,
        0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    uint8_t data2[] = {
        0x31, 0x79, 0x02, 0x21, 0x00, 0x9b, 0x17, 0xa5, 0xd3, 0xac, 0xcc, 0xf3, 0x3c, 0x2e, 0x36, 0x23,
        0x99, 0x78, 0x17, 0x50, 0xc9, 0xdc, 0x3e, 0x1b, 0x57, 0x0e, 0xc9, 0x0b, 0x04, 0x1c, 0x18, 0x24,
        0x5e, 0x71, 0xe9, 0x02, 0x8c, 0x02, 0x20, 0x78, 0xc6, 0x6f, 0xda, 0x59, 0x82, 0xae, 0x5e, 0xb3,
        0x17, 0xd2, 0xe1, 0x9b, 0x73, 0xf6, 0x77, 0xed, 0x57, 0xd5, 0xe3, 0x46, 0xde, 0x6c, 0xc4, 0x19,
        0x38, 0x80, 0x96, 0x4c, 0x13, 0x6d, 0x2c, 0x04, 0x20, 0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac,
        0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47, 0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b,
        0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf, 0x04, 0x10, 0xf5, 0x89, 0xc8, 0xb5, 0xdf,
        0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    uint8_t data3[] = {
        0x30, 0x80, 0x02, 0x21, 0x00, 0x9b, 0x17, 0xa5, 0xd3, 0xac, 0xcc, 0xf3, 0x3c, 0x2e, 0x36, 0x23,
        0x99, 0x78, 0x17, 0x50, 0xc9, 0xdc, 0x3e, 0x1b, 0x57, 0x0e, 0xc9, 0x0b, 0x04, 0x1c, 0x18, 0x24,
        0x5e, 0x71, 0xe9, 0x02, 0x8c, 0x02, 0x20, 0x78, 0xc6, 0x6f, 0xda, 0x59, 0x82, 0xae, 0x5e, 0xb3,
        0x17, 0xd2, 0xe1, 0x9b, 0x73, 0xf6, 0x77, 0xed, 0x57, 0xd5, 0xe3, 0x46, 0xde, 0x6c, 0xc4, 0x19,
        0x38, 0x80, 0x96, 0x4c, 0x13, 0x6d, 0x2c, 0x04, 0x20, 0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac,
        0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47, 0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b,
        0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf, 0x04, 0x10, 0xf5, 0x89, 0xc8, 0xb5, 0xdf,
        0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    uint8_t data4[] = {
        0x30, 0x79, 0x02, 0x21, 0x00, 0x9b, 0x17, 0xa5, 0xd3, 0xac, 0xcc, 0xf3, 0x3c, 0x2e, 0x36, 0x23,
        0x99, 0x78, 0x17, 0x50, 0xc9, 0xdc, 0x3e, 0x1b, 0x57, 0x0e, 0xc9, 0x0b, 0x04, 0x1c, 0x18, 0x24,
        0x5e, 0x71, 0xe9, 0x02, 0x8c, 0x02, 0x21, 0x00, 0x78, 0xc6, 0x6f, 0xda, 0x59, 0x82, 0xae, 0x5e, 0xb3,
        0x17, 0xd2, 0xe1, 0x9b, 0x73, 0xf6, 0x77, 0xed, 0x57, 0xd5, 0xe3, 0x46, 0xde, 0x6c, 0xc4, 0x19,
        0x38, 0x80, 0x96, 0x4c, 0x13, 0x6d, 0x2c, 0x04, 0x20, 0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac,
        0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47, 0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b,
        0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94, 0x1a, 0x4d, 0xaf, 0x04, 0x10, 0xf5, 0x89, 0xc8, 0xb5, 0xdf,
        0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    Crypto_DataBlob sm2Ciphertext1 = {.data = data1, .len = sizeof(data1)/sizeof(data1[0])};
    Crypto_DataBlob sm2Ciphertext2 = {.data = data2, .len = sizeof(data2)/sizeof(data2[0])};
    Crypto_DataBlob sm2Ciphertext3 = {.data = data3, .len = sizeof(data3)/sizeof(data3[0])};
    Crypto_DataBlob sm2Ciphertext4 = {.data = data4, .len = sizeof(data4)/sizeof(data4[0])};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(&sm2Ciphertext1, &spec), CRYPTO_OPERTION_ERROR);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(&sm2Ciphertext2, &spec), CRYPTO_OPERTION_ERROR);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(&sm2Ciphertext3, &spec), CRYPTO_OPERTION_ERROR);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(&sm2Ciphertext4, &spec), CRYPTO_OPERTION_ERROR);

    OH_CryptoSm2CiphertextSpec_Destroy(spec);
}

/**
* @tc.number SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_2100
* @tc.name OHCryptoFrameworkAsymCipherNapiTest.SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_2100
* @tc.desc algorithm is Asym Key
* @tc.size Medium
* @tc.type Func
* @tc.level Level0
*/
HWTEST_F(OHCryptoFrameworkAsymCipherNapiTest, SUB_Security_CryptoFramework_NAPI_AsymCiphery_Test_2100, TestSize.Level0)
{
    OH_CryptoSm2CiphertextSpec *spec = nullptr;
    uint8_t c1_x_data[] = {
        0x8c, 0x02, 0xe9, 0x71, 0x5e, 0x24, 0x18, 0x1c, 0x04, 0x0b, 0xc9, 0x0e, 0x57, 0x1b, 0x3e, 0xdc,
        0xc9, 0x50, 0x17, 0x78, 0x99, 0x23, 0x36, 0x2e, 0x3c, 0xf3, 0xcc, 0xac, 0xd3, 0xa5, 0x17, 0x9b
    };
    uint8_t c1_y_data[] = {
        0x2c, 0x6d, 0x13, 0x4c, 0x96, 0x80, 0x38, 0x19, 0xc4, 0x6c, 0xde, 0x46, 0xe3, 0xd5, 0x57, 0xed,
        0x77, 0xf6, 0x73, 0x9b, 0xe1, 0xd2, 0x17, 0xb3, 0x5e, 0xae, 0x82, 0x59, 0xda, 0x6f, 0xc6, 0x7
    };
    uint8_t c2_data[] = {
        0xf5, 0x89, 0xc8, 0xb5, 0xdf, 0xc6, 0x5e, 0x12, 0xc8, 0x55, 0x6a, 0x1c, 0xe4, 0x6f, 0x47, 0x32
    };
    uint8_t c3_data[] = {
        0xf0, 0xb2, 0x80, 0xed, 0x0b, 0xbe, 0xac, 0xac, 0x80, 0x1c, 0x3c, 0xe0, 0xaa, 0x9f, 0x01, 0x47,
        0xfc, 0xd7, 0x86, 0x1d, 0x33, 0x21, 0x2b, 0x36, 0xeb, 0x8f, 0x16, 0x36, 0x94,
    };
    Crypto_DataBlob c1_x = {.data = c1_x_data, .len = sizeof(c1_x_data)/sizeof(c1_x_data[0])};
    Crypto_DataBlob c1_y = {.data = c1_y_data, .len = sizeof(c1_y_data)/sizeof(c1_y_data[0])};
    Crypto_DataBlob c2 = {.data = c2_data, .len = sizeof(c2_data)/sizeof(c2_data[0])};
    Crypto_DataBlob c3 = {.data = c3_data, .len = sizeof(c3_data)/sizeof(c3_data[0])};
    Crypto_DataBlob sm2Ciphertext = {.data = nullptr, .len = 0};

    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Create(nullptr, &spec), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_X, &c1_x), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C1_Y, &c1_y), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C2, &c2), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_SetItem(spec, CRYPTO_SM2_CIPHERTEXT_C3, &c3), CRYPTO_SUCCESS);
    EXPECT_EQ(OH_CryptoSm2CiphertextSpec_Encode(spec, &sm2Ciphertext), CRYPTO_PARAMETER_CHECK_FAILED);
    
    OH_CryptoSm2CiphertextSpec_Destroy(spec);
    OH_Crypto_FreeDataBlob(&sm2Ciphertext);
}

} // namespace Unittest::CryptoFrameworkAsymCipherNapiTest
